#!/usr/bin/python

import calcul
import unittest


class FakeOption(object):
  def __init__(self, num1, num2, operation):
    self.num1 = num1
    self.num2 = num2
    self.operation = operation


class TestMathF(unittest.TestCase):
  def testAdd(self): 
    self.assertEquals(6, calcul.Add(4, 2))
    self.assertEquals(-2, calcul.Add(-4, 2))
    self.assertEquals(2, calcul.Add(4, -2))
    self.assertEquals(6.4, calcul.Add(4.4, 2))
    self.assertEquals(3.6, calcul.Add(4, -0.4))
    self.assertEquals(4, calcul.Add(4, 0))
    self.assertRaises(ValueError, calcul.Add, 'x', 'x')
    self.assertRaises(ValueError, calcul.Add, 0, 'x')
    self.assertRaises(ValueError, calcul.Add, 'x', 0)
    self.assertRaises(ValueError, calcul.Add, None, None)


  def testSubstract(self):
    self.assertEquals(2, calcul.Subtract(4, 2))
    self.assertEquals(-6, calcul.Subtract(-4, 2))
    self.assertEquals(6, calcul.Subtract(4, -2))
    self.assertAlmostEqual(2.4, calcul.Subtract(4.4, 2))
    self.assertAlmostEqual(4.4, calcul.Subtract(4, -0.4))
    self.assertEquals(4, calcul.Subtract(4, 0))
    self.assertRaises(ValueError, calcul.Subtract, 'x', 'x')
    self.assertRaises(ValueError, calcul.Subtract, 0, 'x')
    self.assertRaises(ValueError, calcul.Subtract, 'x', 0)
    self.assertRaises(ValueError, calcul.Subtract, None, None)


  def testMultiply(self):
    self.assertEquals(8, calcul.Multiply(4, 2))
    self.assertEquals(-8, calcul.Multiply(-4, 2))
    self.assertEquals(-8, calcul.Multiply(4, -2))
    self.assertAlmostEqual(8.8, calcul.Multiply(4.4, 2))
    self.assertAlmostEqual(-1.6, calcul.Multiply(4, -0.4))
    self.assertAlmostEqual(0.0, calcul.Multiply(4, 0))
    self.assertRaises(ValueError, calcul.Multiply, 'x', 'x')
    self.assertRaises(ValueError, calcul.Multiply, 0, 'x')
    self.assertRaises(ValueError, calcul.Multiply, 'x', 0)
    self.assertRaises(ValueError, calcul.Multiply, None, None)


  def testDivide(self):
    self.assertEquals(2, calcul.Divide(4, 2))
    self.assertEquals(-2, calcul.Divide(-4, 2))
    self.assertEquals(-2, calcul.Divide(4, -2))
    self.assertAlmostEqual(2.2, calcul.Divide(4.4, 2))
    self.assertAlmostEqual(-10, calcul.Divide(4, -0.4))
    self.assertRaises(ZeroDivisionError, calcul.Divide, 4, 0)
    self.assertRaises(ValueError, calcul.Divide, 'x', 'x')
    self.assertRaises(ValueError, calcul.Divide, 0, 'x')
    self.assertRaises(ValueError, calcul.Divide, 'x', 0)
    self.assertRaises(ValueError, calcul.Divide, None, None)


 def testCalclate(seft):
    #pre num = 2 operation = add -> zbehne Add() 




if __name__ == '__main__':
  unittest.main()
